package com.example.kt_base.s5


class KtBase84 {
    fun checkLogin(msg: String, code: Int) {
        println("n:$msg,c:$code")
    }
}

fun main() {
    loginApi("lian2", "123456") { msg: String, code: Int ->
        println("n:$msg,c:$code")
    }

    loginApi("lian", "123456", ::checkLogin)

    loginApi("lian2", "123456", result = { msg: String, code: Int ->
        println("n:$msg,c:$code") })

    loginApi("lian", "123456", result = ::checkLogin)
}

fun checkLogin(msg: String, code: Int) {
    println("n:$msg,c:$code")
}

inline fun loginApi(name: String, password: String, result: (String, Int) -> Unit) {
    if (checkUser(name, password)) {
        result("susses", 222)
    } else {
        result("err", 444)
    }
}

fun checkUser(name: String, password: String): Boolean {
    return (name == "lian" && password == "123456")
}


